/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ejb.sessionBeans;

import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import modelo.Contacto;

/**
 *
 * @author inftel
 */
@Stateless
public class ContactoFacade extends AbstractFacade<Contacto> implements ContactoFacadeRemote {
    @PersistenceContext(unitName = "TelePaSOS-ejbPU")
    private EntityManager em;

    protected EntityManager getEntityManager() {
        return em;
    }

    public ContactoFacade() {
        super(Contacto.class);
    }
    
    public List<Contacto> findByUsuario (int id_usuario){
        List<Contacto> list;
        
        list=em.createQuery("SELECT c FROM Contacto c WHERE c.idUsuario.idUsuario = :id")
                                .setParameter("id", id_usuario)
                                .getResultList();       
        return list;
    }
    
}
